<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class ReCaptcha_Lib
{
    public $reCaptcha;
    public $secret;
    public $remote_add;
    public $recaptcha_response;

    public function __construct($params) {
        require_once ('ReCaptcha/recaptchareesponse.php');
        require_once ('ReCaptcha/recaptcha.php');
        $this->secret = $params['secret'];
        $this->remote_add = $params['remote_add'];
        $this->recaptcha_response = $params['recaptcha_response'];
        $this->reCaptcha = new ReCaptcha($this->secret);
    }

    public function verify(){
        $resp = $this->reCaptcha->verifyResponse($this->remote_add, $this->recaptcha_response);
        if ($resp != null && $resp->success){
            return true;
        }
        return false;
    }
}
?>